/**
 * cloud debug 消息
 *
 * @author chitanda
 * @date 2022-11-29 12:11:38
 * @export
 * @class DebugMessage
 */
export class DebugMessage {
  /**
   * 消息类型
   *
   * @author chitanda
   * @date 2022-11-29 12:11:48
   * @type {('REPLY' | 'EVENT')}
   */
  type: 'REPLY' | 'EVENT';

  /**
   * 子类型
   *
   * @author chitanda
   * @date 2022-12-01 15:12:04
   * @type {string}
   */
  subtype: string;

  /**
   * 状态码
   *
   * @description 0 为成功，其他均为失败
   * @author chitanda
   * @date 2022-12-01 15:12:20
   * @type {number}
   */
  code: number;

  /**
   * 回馈唯一标识
   *
   * @author chitanda
   * @date 2022-12-01 15:12:12
   * @type {string}
   */
  id: string;

  /**
   * 异常信息
   *
   * @author chitanda
   * @date 2022-12-01 15:12:43
   * @type {string}
   */
  info: string;

  /**
   * 会话标识
   *
   * @author chitanda
   * @date 2022-12-01 15:12:48
   * @type {string}
   */
  sessionid: string;

  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  data: any;

  /**
   * Creates an instance of DebugMessage.
   * @author chitanda
   * @date 2022-11-29 12:11:37
   * @param {string} message
   */
  constructor(message: string) {
    const data = JSON.parse(message);
    this.type = data.type;
    this.subtype = data.subtype;
    this.code = data.code;
    this.id = data.id;
    this.info = data.info;
    this.data = data.data;
    this.sessionid = data.sessionid;
  }
}
